package com.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Primary;

//@Configuration
public class TestConfig {

    @Bean("accRepo")
    @Demo
    public AccountRespository createJdbcAccountRepo() {
        return new JdbcAccountRepository();
    }

//    @Bean
//    public TransferService createTransferSvc(AccountRespository accountRespository) {
//        return new TransferServiceImpl(accountRespository);
//    }

    //@DependsOn表示该Bean依赖于某个Bean，若所依赖的Bean不存在，则无法创建当前Bean
    @Bean
    @DependsOn("accRepo")
    public TransferService createTransferSvc() {
        return new TransferServiceImpl(createJdbcAccountRepo());
    }

//    @Bean
//    @Primary
//    public TransferService createTransferSvc2() {
//        return new TransferServiceImpl2();
//    }
}
